package com.bingxue.edu.management.education.model.entity;

import com.bingxue.edu.common.enums.ChangeTypeEnum;
import com.bingxue.edu.common.enums.OperateSourceEnum;
import com.bingxue.edu.common.enums.OperateStatusEnum;
import com.bingxue.edu.framework.common.model.AuditableEntity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.handler.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 学生变更记录
 *
 * @author zq
 * @since 2024/08/22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Table("edu_enroll_change_record")
public class EnrollChangeRecord extends AuditableEntity {

    @Schema(description = "报名id")
    private String enrollmentId;

    @Schema(description = "学生id")
    private String studentId;

    @Schema(description = "变更类型")
    private ChangeTypeEnum changeType;

    @Schema(description = "原始班级")
    private String originalClassId;

    @Schema(description = "原始课次顺序列表")
    @Column(typeHandler = JacksonTypeHandler.class)
    private List<Integer> originalLessonIndexes;

    @Schema(description = "目标班级")
    private String targetClassId;

    @Schema(description = "目标课次顺序列表")
    @Column(typeHandler = JacksonTypeHandler.class)
    private List<Integer> targetLessonIndexes;

    @Schema(description = "详情")
    private String details;

    /**
     * 退班退课时，该字段为退款id，报名时为订单item id
     */
    @Schema(description = "业务id")
    private String businessId;

    @Schema(description = "最后一次课次班级id")
    private String lastLessonClassId;

    @Schema(description = "操作来源")
    private OperateSourceEnum operateSource;

    @Schema(description = "操作状态")
    private OperateStatusEnum operateStatus;

    public Integer getLessonLength() {
        return originalLessonIndexes == null ? 0 : originalLessonIndexes.size();
    }

}
